﻿namespace Sample.JQuery {
	using System;
	using System.Web.UI;
	using System.Globalization;

	public partial class DatePickerPage : Page {

		protected override void OnLoad(System.EventArgs e) {
			base.OnLoad(e);

			PostBackOnSelectCheckBox.CheckedChanged += new System.EventHandler(PostBackOnSelectCheckBox_CheckedChanged);
			DatePicker.Select += new System.EventHandler(DatePicker_Select);
			Calendar.Select += new System.EventHandler(Calendar_Select);

		}

		private void PostBackOnSelectCheckBox_CheckedChanged(object sender, System.EventArgs e) {
			bool postBackOnSelect = PostBackOnSelectCheckBox.Checked;
			DatePicker.PostBackOnSelect = postBackOnSelect;
			Calendar.PostBackOnSelect = postBackOnSelect;
		}

		private void DatePicker_Select(object sender, System.EventArgs e) {
			PostBackOnSelectLabel.Text = Server.HtmlEncode(string.Format(CultureInfo.InvariantCulture,
				"The date \"{0}\" was selected at {1} with the Dropdown Date Picker.",
				DatePicker.SelectedDate.HasValue ? DatePicker.SelectedDate.Value.ToShortDateString() : string.Empty,
				DateTime.Now.ToLongTimeString()));
		}

		private void Calendar_Select(object sender, System.EventArgs e) {
			PostBackOnSelectLabel.Text = Server.HtmlEncode(string.Format(CultureInfo.InvariantCulture,
				"The date \"{0}\" was selected at {1} with the Inline Calendar.",
				Calendar.SelectedDate.HasValue ? Calendar.SelectedDate.Value.ToShortDateString() : string.Empty,
				DateTime.Now.ToLongTimeString()));
		}

	}

}